home *** CD-ROM | disk | FTP | other *** search
- 0 rem << cd36-3 >>
- 1 rem commodares problem #32-1:
- 2 print"[147] diligent decoder"
- 3 rem solution by
- 4 rem matt shapiro
- 5 rem (also #28-4:elegant encoder)
- 6 rem
- 10 dim w(28):def fnm(x)=x-29*int(x/29)
- 20 input"what's your word";w$
- 30 print"e[146]ncode or d[146]ecode? ";
- 40 get a$:if a$<"d" or a$>"e" then 40
- 50 print a$:l=len(w$):s=0:if l<2 or l>29 then 20
- 60 for i=1 to l:w(i)=asc(mid$(w$,i,1))-64:s=s+w(i):next:w$="":if a$="e" then100
- 70 s=fnm(s)
- 80 q=s/(l-1):ifq<>int(q) then s=s+29:goto 80
- 90 s=q
- 100 for i=1 to l:w$=w$+chr$(fnm(s-w(i))+64):next:print w$:end
-